<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>后盾人</title>
  </head>
  <body>
    <script>
      const date = new Date("1992-2-12 10:22:18");
      function dateFormat(date, format = "YYYY-MM-DD HH:mm:ss") {
        const config = {
          YYYY: date.getFullYear(),
          MM: date.getMonth(),
          DD: date.getDate(),
          HH: date.getHours(),
          mm: date.getMinutes(),
          ss: date.getSeconds()
        };
        for (const key in config) {
          format = format.replace(key, config[key]);
        }
        return format;
      }
      console.log(dateFormat(date, "YYYY年MM月DD日"));
      // console.log(date);
      // console.log(date.getFullYear());
      // console.log(date.getMonth() + 1);
      // console.log(date.getDate());
      // console.log(date.getHours());
      // console.log(date.getMinutes());
      // console.log(date.getSeconds());

      // const formatDate = `${date.getFullYear()}年${date.getMonth() + 1}月`;
      // console.log(formatDate);
    </script>
  </body>
</html>
